﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApplication4
{
    /// <summary>
    /// Interaction logic for ExternalConnector.xaml
    /// </summary>
    public partial class ExternalConnector : System.Windows.Controls.Label
    {
        public delegate void DeviceDel(long x);

        private Wire wire = null;
        private DeviceDel deviceCallback;
        public ExternalConnector()
        {
            InitializeComponent();

            this.MouseEnter += new MouseEventHandler(this.my_MouseEnter);
            this.MouseLeave += new MouseEventHandler(this.my_MouseLeave);
        }

        public void my_MouseEnter(object sender, MouseEventArgs e)
        {
            this.Background = Brushes.LightCoral;
        }

        public void my_MouseLeave(object sender, MouseEventArgs e)
        {
            this.Background = Brushes.LightGreen;
        }

        // Functions for device
        /// <summary>
        /// Write to wire from device
        /// </summary>
        /// <param name="x"></param>
        public void write(long x) {
            wire.writeWire(this, x);
        }
        public void registerCallback(DeviceDel x) {
            deviceCallback = x;
        }

        // Functions for WIRE
        public void connectWire(Wire x) {
            wire = x;
        }
        public void disconnectWire(Wire x) {
            wire = null;
        }
        public void wireCallback(long x)
        {
            deviceCallback(x);
        }
    }
}
